#!/bin/bash



####  Compile mode
read -p "Please input your compile mode(1:compile, 2.only compile for UI, 3:Clean Build): "  compile_mode
if [ "$compile_mode" == "1" ]; then
	continue
elif [ "$compile_mode" == "2" ]; then
	make ui; exit
elif [ "$compile_mode" == "3" ]; then
	make clean
	continue
else
	echo "I don't know what your choice is"; exit
fi	
echo -e "\n"
######################################



echo -e "\n"
#####  remote control
read -p "Please input your remote control(1:YJ1, 2:YJ2,3:ARC20): " rc_model

if [ "$rc_model" == "1" ]; then
	#create tmp.conf
	test -e tmp.conf || (touch tmp.conf && echo "YAOJIN01" >tmp.conf)
	if [ "$compile_mode" == "1" ]; then
		while read line
		do	test -z $line && echo "YAOJIN01" >tmp.conf
			test $line != "YAOJIN01" &&rc_cmd="AOV_RC_MODEL=YAOJIN02" \
			name_cmd="AOV_PRODUCT_NAME=ISB277_B" \
			||rc_cmd="AOV_RC_MODEL=YAOJIN01" \
			name_cmd="AOV_PRODUCT_NAME=ISB277_A"
		done < tmp.conf
		echo $rc_cmd
		echo $name_cmd
	else
		echo "YAOJIN01" > tmp.conf
		rc_cmd="AOV_RC_MODEL=YAOJIN01"
		name_cmd="AOV_PRODUCT_NAME=ISB277_A"
	fi
elif [ "$rc_model" == "2" ]; then
	#create tmp.conf
	test -e tmp.conf || (touch tmp.conf && echo "YAOJIN02" >tmp.conf)
	if [ "$compile_mode" == "1" ]; then
		while read line
		do  test -z $line && echo "YAOJIN02" >tmp.conf 
			test $line != "YAOJIN02" &&rc_cmd="AOV_RC_MODEL=YAOJIN01" \
			name_cmd="AOV_PRODUCT_NAME=ISB277_A" \
			||rc_cmd="AOV_RC_MODEL=YAOJIN02" \
			name_cmd="AOV_PRODUCT_NAME=ISB277_B"
		done <tmp.conf
		echo $rc_cmd
		echo $name_cmd
	else
		echo "YAOJIN02" > tmp.conf
		rc_cmd="AOV_RC_MODEL=YAOJIN02"
		name_cmd="AOV_PRODUCT_NAME=ISB277_B"
	fi
elif [ "$rc_model" == "3" ]; then
	rc_cmd="AOV_RC_MODEL=ARC020"
else
	echo "I don't know what your choice is"; exit
fi
echo -e "\n"
#################################

####  Tuner
read -p "Please input your tuner(1:MXL603, 2:MXL5007): " tun_model

if [ "$tun_model" == "1" ]; then
	tun_cmd="AOV_TUN_MODULE=TUNER_MXL603"
elif [ "$tun_model" == "2" ]; then
	tun_cmd="AOV_TUN_MODULE=TUNER_MXL5007"
else
	echo "I don't know what your choice is"; exit
fi
echo -e "\n"

if [ "$compile_mode" == "3" ]; then
echo -e "\n"

make path 
make $rc_cmd $tun_cmd $name_cmd config
make $rc_cmd $tun_cmd $name_cmd new
make $rc_cmd $tun_cmd $name_cmd ddk
fi
make $rc_cmd $tun_cmd $name_cmd product_7z
